package com.sangeng.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sangeng.entity.UserRole;
import com.sangeng.mapper.UserRoleMapper;
import com.sangeng.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户和角色关联表(UserRole)表服务实现类
 *
 * @author makejava
 * @since 2022-08-27 13:54:03
 */
@Service("userRoleService")
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
@Resource
UserRoleMapper userRoleMapper;
    @Override
    public List<String> getRoleByUserId(Long id) {
        if(id==1){
            ArrayList<String> strings = new ArrayList<>();
            strings.add("admin");
            return strings;
        }
        //一个用户可能有多个角色
         List<String> roleList = userRoleMapper.getRoleByUserId(id);


        return roleList;
    }
}

